﻿
#ifndef __NGX_PUBLIC_H__
#define __NGX_PUBLIC_H__

#include <stdio.h>
#include <stdarg.h>
#include <sys/msg.h>

#include "UserServer.h"
#include<algorithm>

#define _PKG_HD_INIT					0  //初始状态，准备接收数据包头
#define _PKG_HD_RECVING			1  //接收包头中，包头不完整，继续接收中
#define _PKG_BD_INIT					2  //包头刚好收完，准备接收包体
#define _PKG_BD_RECVING			3  //接收包体中，包体不完整，继续接收中，处理后直接回到_PKG_HD_INIT状态

using namespace std;
extern							CUserServer *g_pServer;
typedef unsigned char       ubyte;
typedef unsigned short      ushort;
typedef unsigned int        uint;
typedef long long           int64;
typedef unsigned long long  uint64;
typedef long double         float128;
typedef long double         real;

typedef size_t(*RsaKeyGenerate)(int bitLength, char* resultss);
typedef size_t(*RsaKeyGenerateInit)(int bitLength, char* privateKey, char* publicKey);
typedef long(*RsaEncrypt)(char* key, int keyLength, ubyte* data, size_t len, ubyte* result);
typedef long(*RsaDecrypt)(char* key, int keyLength, ubyte* data, size_t len, ubyte* result);
typedef long(*RsaDecrypt2)(char* key, int keyLength, ubyte* data, size_t len, ubyte* uInMemry, ubyte* result);


extern size_t							g_TcpHeaderSize;                       //sizeof(COMM_PKG_HEADER);		
extern size_t							g_TcpMsgSize;                       //sizeof(STRUC_MSG_HEADER);

extern RsaDecrypt					g_pRsaDecrypt;
extern RsaDecrypt2				g_pRsaDecrypt2;
extern RsaKeyGenerate		    pRsaKeyGenerate;
#define			PageSize_Send						     2
#define			Session_ID_Lenth						 0
#define			MY_DEBUG								 1
#define			MY_OUT									 1
#define			GetDeviceTime							 1
#define			SIZE_SMALL								16
#define			SIZE_BIG									512
#define			SIZE_DMX									1024
#define			SIZE_PassThrough						2200
//进程相关----------------------
//标记当前进程类型
#define NGX_PROCESS_MASTER      0  //master进程，管理进程
#define NGX_PROCESS_WORKER     1  //worker进程，工作进程
//.......其他待扩展
//  int    ngx_init_signals();

  typedef struct LoginInfo
  {
      char  username[64];
      int   m_fd;
  } LoginInfo;

 struct Msg_Info
  {
          long int      msg_type;
          char           text[BUFSIZ];
  };
 typedef  struct  UserInfoMaster
 {
	 char		 szUserName[64];
	 int          nWorkerProcessPid;
	 
	 bool operator ==(const string& x)
	 {
		 return(this->szUserName == x);
	 }
 }UserInfoMaster;

 typedef  struct  UserInfoWorker
 {
	 char		 szUserName[64];
	 int          nWorkerProcessPid;
	 sClient	* p_Conn;
	 bool operator ==(const string& x)
	 {
		 return(this->szUserName == x);
	 }
 }UserInfoWorker;


enum  	 DATA_TYPE
{
	TYPE_Char = 0,
	TYPE_Integer = 1,
	TYPE_Double = 2,
	TYPE_bool = 3
};



//#define    MULTIPLE_PROCESS   1
 extern  std::vector<UserInfoMaster >				m_VectorLoginUserMaster;
 extern  std::vector<UserInfoWorker >				m_VectorLoginUserWorker;



























#endif
